home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / AmiVoGL_MDEV.lha / src / newtoken.c < prev    next >
C/C++ Source or Header  |  1992-03-05  |  813b  |  43 lines

  1. #include <stdio.h>
  2. #include "vogl.h"
  3.  
  4. static TokList        *current;
  5.  
  6. /*
  7.  * newtokens
  8.  *
  9.  *    returns the space for num tokens
  10.  */
  11. Token * newtokens(int num)
  12. {
  13.     TokList    *tl;
  14.     Token    *addr;
  15.     int    size;
  16.  
  17.     if (vdevice.tokens == (TokList *)NULL || num >= MAXTOKS - current->count) {
  18.         if ((tl = (TokList *)malloc(sizeof(TokList))) == (TokList *)NULL)
  19.             verror("newtokens: malloc returns NULL");
  20.  
  21.         if (vdevice.tokens != (TokList *)NULL)
  22.             current->next = tl;
  23.         else 
  24.             vdevice.tokens = tl;
  25.  
  26.         tl->count = 0;
  27.         tl->next = (TokList *)NULL;
  28.         if (num > MAXTOKS)
  29.             size = num;
  30.         else
  31.             size = MAXTOKS;
  32.         if ((tl->toks = (Token *)malloc(size * sizeof(Token))) == (Token *)NULL)
  33.             verror("newtokens: malloc returns NULL");
  34.  
  35.         current = tl;
  36.     }
  37.  
  38.     addr = ¤t->toks[current->count];
  39.     current->count += num;
  40.  
  41.     return(addr);
  42. }
  43.